package io.renren.modules.cuttingmachinehisdata.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.cuttingmachinehisdata.entity.CuttingmachineHisdataEntity;
import io.renren.modules.cuttingmachinehisdata.service.CuttingmachineHisdataService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

@RestController
@RequestMapping("cuttingmachinehisdata/cuttingmachinehisdata")
public class CuttingmachineHisdataController {
    @Autowired
    private CuttingmachineHisdataService cuttingmachineHisdataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("cuttingmachinehisdata:cuttingmachinehisdata:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cuttingmachineHisdataService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{no}")
    @RequiresPermissions("cuttingmachinehisdata:cuttingmachinehisdata:info")
    public R info(@PathVariable("no") Integer no){
		CuttingmachineHisdataEntity cuttingmachineHisdata = cuttingmachineHisdataService.getById(no);

        return R.ok().put("cuttingmachineHisdata", cuttingmachineHisdata);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("cuttingmachinehisdata:cuttingmachinehisdata:save")
    public R save(@RequestBody CuttingmachineHisdataEntity cuttingmachineHisdata){
		cuttingmachineHisdataService.save(cuttingmachineHisdata);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("cuttingmachinehisdata:cuttingmachinehisdata:update")
    public R update(@RequestBody CuttingmachineHisdataEntity cuttingmachineHisdata){
		cuttingmachineHisdataService.updateById(cuttingmachineHisdata);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("cuttingmachinehisdata:cuttingmachinehisdata:delete")
    public R delete(@RequestBody Integer[] nos){
		cuttingmachineHisdataService.removeByIds(Arrays.asList(nos));

        return R.ok();
    }

}
